package com.kc.web.controller.business;

import com.kc.business.domain.BizMarket;
import com.kc.business.service.IBizMarketService;
import com.kc.common.annotation.Log;
import com.kc.common.annotation.RepeatSubmit;
import com.kc.common.core.controller.BaseController;
import com.kc.common.core.domain.AjaxResult;
import com.kc.common.core.page.TableDataInfo;
import com.kc.common.enums.BusinessType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * TODO
 * 市场管理
 *
 * @author zhangshuo
 * @version 1.0
 * @date 2020/10/14
 */
@RestController
@RequestMapping("/business/market")
@Slf4j
public class BizMarketController extends BaseController {
    @Autowired
    private IBizMarketService marketService;

    /**
     * 获取市场列表
     */
    @PreAuthorize("@ss.hasPermi('business:literaryEnter:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizMarket market) {
        startPage();
        List<BizMarket> list = marketService.getList(market);
        return getDataTable(list);
    }

    /**
     * 修改市场
     */
    @PreAuthorize("@ss.hasPermi('business:literaryEnter:edit')")
    @Log(title = "市场管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @RepeatSubmit
    public AjaxResult edit(@RequestBody BizMarket market) {
        return toAjax(marketService.edit(market));
    }
    /**
     * 添加市场
     */
    @PreAuthorize("@ss.hasPermi('business:literaryEnter:add')")
    @Log(title = "市场管理", businessType = BusinessType.INSERT)
    @PostMapping
    @RepeatSubmit
    public AjaxResult add(@RequestBody BizMarket market) {
        return toAjax(marketService.add(market));
    }
}
